import requests
import log

def if_locked():
    url = "https://gitee.com/zhu-zehang/cross-border-e-commerce-wizard/raw/master/lock.txt"
    try:
        response = requests.get(url)
        response.raise_for_status()  # 检查请求是否成功
        content = response.text.strip().lower()
        return content == "true"  # 如果内容为"true"则返回True
    except requests.RequestException as e:
        log.Debug(f"获取锁定状态出错: {e}")
        return True  # 如果请求出错也返回True

def check_date_lock(username, passwd):
    """
    向 /api_login 接口发送登录请求

    :param username: 用户名
    :param password: 密码
    :return: 响应的 JSON 数据
    """
    url = "http://154.64.255.89:5000/api_login"  # 根据实际情况修改主机和端口
    data = {
        "username": username,
        "passwd": passwd
    }
    try:
        response = requests.post(url, json=data)
        response.raise_for_status()  # 检查请求是否成功
        log.Debug(response.json())
        return response.json()['status']
    except requests.RequestException as e:
        print(f"请求出错: {e}")
        return None

if __name__ == '__main__':
    print(check_date_lock('test2', '123456'))